﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GUI.UserControls
{
    public partial class ImageButton : Button 
    {        
        public ImageButton()
        {
            InitializeComponent();
        }

        public enum ButtonType
        {
            REFRECH,
            ADD,
            SET,
            ALLERA,
            DELETE,
            COLUMN,
            CANCEL,
            SAVE
        }
        public override Color BackColor
        {
            get { return Color.FromArgb(240, 240, 240); }
        }

        
		ButtonType _aspect = ButtonType.ADD;
        [EditorBrowsable(EditorBrowsableState.Always)]
        [Browsable(true)]
        [Bindable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public ButtonType Aspect
        {
            get { return _aspect; }
            set
            {
                _aspect = value;
                switch (_aspect)
                {
                    case ButtonType.REFRECH :
                        theButton.BackgroundImage = global::GUI.Properties.Resources.btnRafraichir;
                        theButton.BackColor = Color.FromArgb(72, 72, 72);
                        theLabel.Text = "Rafraichir";
                        break;
                    case ButtonType.ADD:
                        theButton.BackgroundImage = global::GUI.Properties.Resources.btnAjouter;
                        theButton.BackColor = Color.FromArgb(72, 72, 72);
                        theLabel.Text = "Ajouter";
                        break;
                    case ButtonType.SET:
                        theButton.BackgroundImage = global::GUI.Properties.Resources.btnModifier;
                        theButton.BackColor = Color.FromArgb(72, 72, 72);
                        theLabel.Text = "Modifier";
                        break;
                    case ButtonType.DELETE:
                        theButton.BackgroundImage = global::GUI.Properties.Resources.btnSupprimer;
                        theButton.BackColor = Color.FromArgb(72, 72, 72);
                        theLabel.Text = "Supprimer";
                        break;
                    case ButtonType.ALLERA:
                        theButton.BackgroundImage = global::GUI.Properties.Resources.btnAllerA;
                        theButton.BackColor = Color.FromArgb(72, 72, 72);
                        theLabel.Text = "Aller A";
                        break;

                    case ButtonType.COLUMN:
                        theButton.BackgroundImage = global::GUI.Properties.Resources.btnColonnes;
                        theButton.BackColor = Color.FromArgb(72, 72, 72);
                        theLabel.Text = "Colonnes";
                        break;
                    case ButtonType.CANCEL:
                        theButton.BackgroundImage = global::GUI.Properties.Resources.btnAnnuler;
                        theButton.BackColor = Color.FromArgb(240, 145, 43);
                        theLabel.Text = "Annuler";
                        break;
                    case ButtonType.SAVE:
                        theButton.BackgroundImage = global::GUI.Properties.Resources.btnSauvegarder;
                        theButton.BackColor = Color.FromArgb(240, 145, 43);
                        theLabel.Text = "Enregistrer";
                        break;
                }
            }
        }


        private void theButton_Click(object sender, EventArgs e)
        {
            this.PerformClick();
        }
    }
}
